//
//  NewFeatureViewCell.m
//  weibo110
//
//  Created by 臧松 on 15/12/28.
//  Copyright © 2015年 臧松. All rights reserved.
//

#import "NewFeatureViewCell.h"
#import "Masonry.h"
#import "UIButton+Extension.h"
@interface NewFeatureViewCell ()
@property (nonatomic,strong) UIButton * startButton;
@property (nonatomic,strong) UIImageView * iconView;

@end

@implementation NewFeatureViewCell

// 懒加载控件
-(void)setImageIndex:(NSIndexPath *)imageIndex{
    _imageIndex = imageIndex;
    self.iconView.image = [UIImage imageNamed:[NSString stringWithFormat:@"new_feature_%ld",imageIndex.item + 1]];
    self.startButton.hidden = YES;
}
-(UIImageView *)iconView{
    if (_iconView == nil) {
        _iconView = [[UIImageView alloc]init];
    }
    return _iconView;
}
-(UIButton *)startButton{
    if (_startButton == nil) {
        
        _startButton = [UIButton btnWithTitle:@"开始体验" color:[UIColor whiteColor] imageName:@"new_feature_finish_button"];
        [_startButton addTarget:self action:@selector(startBtnClick) forControlEvents:UIControlEventTouchUpInside];
    }
    return _startButton;
}
// 初始化方法
-(instancetype)initWithFrame:(CGRect)frame{
    
    if (self = [super initWithFrame:frame]) {
        
        [self addSubview:self.iconView];
        [self addSubview:self.startButton];
       
        [self.startButton mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerX.equalTo(self.mas_centerX);
            make.bottom.equalTo(self.mas_bottom).multipliedBy(0.7);
        }];
        
        self.iconView.frame = self.bounds;
    }
    return self;
}
-(void)startBtnClick{
    NSLog(@"开始体验");
    [[NSNotificationCenter defaultCenter]postNotificationName:@"WBRootViewController" object:nil userInfo:nil];
}
-(void)showButtonAnim{
    self.startButton.hidden = NO;
    self.startButton.transform = CGAffineTransformMakeScale(0, 0);
    [UIView animateWithDuration:1.6 delay:0 usingSpringWithDamping:0.6 initialSpringVelocity:10 options:UIViewAnimationOptionLayoutSubviews animations:^{
        
        self.startButton.transform = CGAffineTransformIdentity;
    } completion:^(BOOL finished) {
        NSLog(@"ok");
    }];
}

@end
